<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Globals_model extends CI_Model 
{
	function __construct()
	{
		parent:: __construct();
	}
	function getDetailVen($Venid)
	{
		/*$sql	= "	SELECT B.HR_ID, C.NAME, C.ORG, C.JOB_POSITION, (SELECT DISTINCT(NAME) NAME FROM HRS WHERE ID = C.MANAGER) MANAGER, C.EMPLOYEE_TYPE
					FROM LOGINS B, HRS C 
					WHERE NOT C.NAME = 'Administrator' AND B.HR_ID = C.ID AND C.ID = ".$Nik; */
        $sql	= "	
            select vendor_id, vendor_name, PIC 
            from lkk_vendor_mst  
            where vendor_id = '$Venid'"
        ;            
		$result = $this->db->query($sql);
		$Udata 	= $result->row_array();
		$Rdata 	= $result->num_rows();
		if ($Rdata > 0)
		{
			return $Udata;
		}
		else
		{
			return FALSE;
		}
	}
	function getSearchEmp($Name)
	{
		$sql = "SELECT b.ID, b.NAME FROM LOGINS a, HRS b WHERE NOT b.NAME = 'Administrator' AND a.hr_id = b.id AND LOWER(b.NAME) LIKE LOWER('%".$Name."%')";
		$result = $this->db->query($sql);
		$Udata = $result->result_array();
		$Rdata = $result->num_rows();
		if ($Rdata > 0)
		{
			return $Udata;
		}
		else
		{
			return FALSE;
		}
	}
    //add bu Andi on 29/08/2014
    function getSearchEmpGlobal($Name)
	{
		$sql = "
        select to_char(b.contract_sdate,'dd/mm/yyyy') contract_sdate, to_char(b.contract_edate,'dd/mm/yyyy') contract_edate, 
        a.hr_id as ID, b.name as NAME, b.org, b.job_position, b.status 
        from logins a, hrs b 
        where a.hr_id = b.id 
            and upper(b.location) like 'HEAD OFFICE%' 
            and LOWER(b.NAME) LIKE LOWER('%".$Name."%')
        order by b.name asc
        ";
		$result = $this->db->query($sql);
		$Udata = $result->result_array();
		$Rdata = $result->num_rows();
		if ($Rdata > 0)
		{
			return $Udata;
		}
		else
		{
			return FALSE;
		}
	}
    //=
	
	function getDetailEmp($Nik)
	{   
	    //edit by andi siswanto on 22/08/2014 +MANAGER_ID
		$sql	= "	SELECT B.HR_ID, C.NAME, C.ORG, C.JOB_POSITION, C.MANAGER as MANAGER_ID, (SELECT DISTINCT(NAME) NAME FROM HRS WHERE ID = C.MANAGER) MANAGER, C.EMPLOYEE_TYPE
					FROM LOGINS B, HRS C 
					WHERE NOT C.NAME = 'Administrator' AND B.HR_ID = C.ID AND C.ID = ".$Nik;
		$result = $this->db->query($sql);
		$Udata 	= $result->row_array();
		$Rdata 	= $result->num_rows();
		if ($Rdata > 0)
		{
			return $Udata;
		}
		else
		{
			return FALSE;
		}
	}
}